package com.gopay.webtest.controller.cloud;

import java.util.Date;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.gopay.webtest.controller.base.BaseController;
import com.gopay.webtest.handler.cloud.TransCloudSignHandler;
import com.gopay.webtest.util.DateUtils;
import com.gopay.webtest.vo.cloud.Cloud0604Vo;
import com.gopay.webtest.xml.XmlDao;

/**
 * 冻结解冻
 * ZhangZG
 * 2016年1月8日 
 * www.gopay.com.cn Inc.All rights reserved.
 */
@Controller
@RequestMapping("/cloud/froztha")
public class FrozenThawController extends BaseController{
	
	@Resource(name = "xmlDao")
    private XmlDao xmlDao;
	
	@Resource(name="transCloudSignHandler")
	private TransCloudSignHandler transCloudSignHandler;
	
	   @RequestMapping("/froFrozenThawApply")
	    public ModelAndView chargeApply() {
	        ModelAndView mv = new ModelAndView();

	        
	        try {
	        	this.logger.error("^^^^^^^^^^^^^^^^^云平台账户解冻冻结申请页面初始化成功^^^^^^^^^^^^^^^^^");
	        	
	        	 Map<String, String> map = xmlDao.readData4Map("cloud_apply", "apply");

	             map.put("gopayServerTime", DateUtils.format(new Date(), "yyyyMMddHHmmss"));
	             map.put("merOrderNum", System.currentTimeMillis()+"");
	             mv = new ModelAndView("cloud.frotha.apply");
	             mv.addObject("config", map);
	        	
	        } catch (Exception e) {
	            logger.error("跳转页面", e);
	        }

	        return mv;
	    }
	    
	    
	    @RequestMapping("/doFrozenThawThaSubmit")
	    public ModelAndView doCharge(@ModelAttribute Cloud0604Vo req){
	    	 ModelAndView mv = new ModelAndView();
			 mv.setViewName("cloud.frotha.doApply");

			try {
	        	 this.logger.error("^^^^^^^^^^^^^^^^^云平台账户解冻冻结申请页面签名成功^^^^^^^^^^^^^^^^^");
	             // 签名
	        	 transCloudSignHandler.sign(req.getTranCode()+"_"+req.getVersion(), "signType", "signValue", req, getRequest());

	             mv.addObject("applyVo", req);
	         } catch (Exception e) {
	             logger.error("执行申请", e);
	         }
	         return mv;
	    }
}
